package cn.rongdao.jrkabao.ui.cashadvance.adapter;

import android.view.View;

import com.mifengkong.frtools.ui.adapter.recyclerview.FRBaseRecyclerViewHolder;

import cn.rongdao.jrkabao.bean.cashadvance.CreditAndDepositCardBean;
import cn.rongdao.jrkabao.ui.cashadvance.uicomponent.ItemCreditAndBankCardUIComponent;

/**
 * Created by jack on 2017/6/2
 */

public class CreditAndDepositViewHolder extends FRBaseRecyclerViewHolder<CreditAndDepositCardBean> {

    private OnCreditCardClickListener onCreditCardClickListener;

    private ItemCreditAndBankCardUIComponent itemCreditAndBankCardUIComponent;

    public CreditAndDepositViewHolder(View view, OnCreditCardClickListener onCreditCardClickListener) {
        super(view);

        itemCreditAndBankCardUIComponent = (ItemCreditAndBankCardUIComponent) view;
        this.onCreditCardClickListener = onCreditCardClickListener;
        initListener();
    }

    private void initListener() {
        itemCreditAndBankCardUIComponent.setOnDeleteListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != onCreditCardClickListener) {
                    onCreditCardClickListener.onDeleteClick(v, getLayoutPosition());
                }
            }
        });
        itemCreditAndBankCardUIComponent.setOnSettingListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != onCreditCardClickListener) {
                    onCreditCardClickListener.onSettingClick(v, getLayoutPosition());
                }
            }
        });
    }

    @Override
    protected void onItemDataUpdated(CreditAndDepositCardBean data) {
        itemCreditAndBankCardUIComponent.setContent(data);
    }
}